package com.company.demo;

import xyz.noark.core.annotation.TemplateConverter;
import xyz.noark.core.converter.AbstractConverter;

/**
 * 字符串到对象的过程
 *
 * @author 小流氓[176543888@qq.com]
 */
@TemplateConverter(SimpleItem.class)
public class SimpleItemConverter extends AbstractConverter<SimpleItem> {

    @Override
    public String buildErrorMsg() {
        return "格式不对噢...例>>道具编号:数量";
    }

    @Override
    protected SimpleItem convert(String value) throws Exception {
        String[] array = value.split(":", 2);
        return new SimpleItem(array[0], Integer.parseInt(array[1]));
    }
}